package cn.wegoteam.shop.po;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import cn.wegoteam.shop.enu.AgentType;
@Entity
@Table(name = "agent", catalog = "shop")
public class Agent extends BasePo implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private User user;
    private AgentType type;//代理类型
    private String email;//常用邮箱
    private String phone;//联系电话
    private String name;//公司名称或个人姓名
    private String imgUrl;//身份证照片或者公司执照照片
    private String message;//加盟理由
    private Timestamp insertTime;
    private Integer flag;
    @Transient
	public String getFormatStrTime(){
    	return this.insertTime.toString().substring(0,this.insertTime.toString().lastIndexOf(" ")).trim();
    }
    @Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id){
		this.id=id;
	}
    @OneToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="uid",insertable=true,unique=true)
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@Column(name="type",length=12,nullable = true)
    @Enumerated(EnumType.STRING)
	public AgentType getType() {
		return type;
	}
	public void setType(AgentType type) {
		this.type = type;
	}
	@Column(name = "email", length = 32)
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Column(name = "phone", length = 32)
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	@Column(name="imgUrl",length=100)
	public String getImgUrl() {
		return imgUrl;
	}
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}
	@Column(name="message",length = 65535)
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	@Column(name = "insertTime", length = 32,nullable = true,insertable=false,updatable=false)
	public Timestamp getInsertTime() {
		return insertTime;
	}
	public void setInsertTime(Timestamp insertTime) {
		this.insertTime = insertTime;
	}
	
	@Column(name = "flag",nullable = true,insertable=false)
	public Integer getFlag() {
		return this.flag;
	}
	public void setFlag(Integer flag){
		this.flag=flag;
	}
	@Column(name = "name",nullable = true)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

}
